package cn.itsource.ymcc.consumer;

import cn.itsource.ymcc.service.IKillCourseService;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

@Component
@RocketMQMessageListener(
        consumerGroup = "killtimeoutGroup",
        topic = "killtimeout-topic",
        selectorExpression = "killtimeout-tag"
)
public class KillConsumer implements RocketMQListener<MessageExt> {
    @Autowired
    private IKillCourseService killCourseService;
    @Override
    public void onMessage(MessageExt messageExt) {
        if (messageExt.getBody() == null || messageExt.getBody().length == 0)return;
        String s = new String(messageExt.getBody(), StandardCharsets.UTF_8);
        killCourseService.killOrderOut(s);
    }
}
